package org.wzys.Mapper;

import org.apache.ibatis.annotations.*;
import org.wzys.Pojo.Order;
import org.wzys.Pojo.OrderItem;
import org.wzys.Pojo.Review;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper {

    void insertOrder(Order order);

    void insertOrderItem(OrderItem orderItem);

    @Update("update orders set total_amount = #{totalAmount} where order_id = #{a}")
    void insertprise(String a, BigDecimal totalAmount);

    @Update("update orders set status = 1 ,created_time=#{now} where order_id = #{orderId} ")
    void updateOrderStatus(String orderId,LocalDateTime now);

    @Select("select product_id from order_item where order_id = #{orderId}")
    List<Integer> getProductIdList(String orderId);

    @Delete("delete from order_item where order_id = #{orderId}")
    void deleteOrderitem(String orderId);

    @Delete("delete from orders where order_id = #{orderId}")
    void deleteOrder(String orderId);

    @Select("select * from orders")
    List<Order> showOrder();


    @Insert("insert into review (order_id, user_id, rating, comment, created_time) " +
            "values (#{orderId},#{userId},#{rating},#{comment},#{createdTime})")
    void addReview(Review review);

    @Select("select * from review where order_id = #{orderId}")
    List<Review> showReview(String orderId);
}
